package net.cyue.easyconfiguration.node.converter;

import net.cyue.easyconfiguration.node.api.INodeTypeConverter;
import net.cyue.util.ReflectUtil;

public class Node2InstanceConverter implements INodeTypeConverter<String, Object> {
    @Override
    public Object convert(String value, String... paths) {
        try {
            Class<?> clz = Thread.currentThread().getContextClassLoader().loadClass(value);
            return ReflectUtil.createInstance(clz);
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }
}
